home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / cenvi2.arj / DEVIOCTL.LIB < prev    next >
Text File  |  1993-10-30  |  4KB  |  76 lines

  1. // DevIOCtl.lib - Interface to the DosDevIOCtl call
  2.  
  3. #define  _DEVIOCTL_LIB   1
  4.  
  5. DosDevIOCtl(DevHandle,Category,Function,
  6.             ParameterBLOb,MaxRetParameterSize,ParameterSize,
  7.             DataBLOb,MaxRetDataSize,DataSize)
  8.    // DevHandle: Device handle, such as returned by DosOpen()
  9.    // Category: Device Categoring for this IOCtl call
  10.    // Function: Function code within that Category
  11.    // ParameterBLOb: Command-specific argument for this Category and Function,
  12.    //           or NULL if this function takes no arguments
  13.    // MaxRetParameterSize: For function calls that return arguments in ParameterBLOb,
  14.    //           this is the maximum size those arguments can be.  If this is
  15.    //           not 0 then ParameterBLOb will be made big enough.  If zero then
  16.    //           this assumes that function returns no parameters in ParameterBLOb.
  17.    // ParameterSize: On input, this is the size of Parameters in ParameterBLOb, on
  18.    //           output this is the size of bytes that Function returned in ParameterBlob.
  19.    //           If MaxRetParameterSize is 0 then this value is not altered.
  20.    //           If this function returns ERROR_BUFFER_OVERFLOW then this contains
  21.    //           the size of the buffer required to hold parameters
  22.    // DataBLOb: Command-specific data for this Category and Function,
  23.    //           or NULL if this function uses no data area
  24.    // MaxRetDataSize: For function calls that return data in this data area,
  25.    //           this is the maximum size that data can be.  If this is
  26.    //           not 0 then DataBLOb will be made big enough.  If zero then
  27.    //           this assumes that function returns no data in DataBLOb.
  28.    // DataSize: On input, this is the size of data area DataBLOb, on
  29.    //           output this is the size of bytes that Function returned in DataBlob.
  30.    //           If MaxRetDataSize is 0 then this value is not altered.
  31.    //           If this function returns ERROR_BUFFER_OVERFLOW then this contains
  32.    //           the size of the buffer required to the data.
  33.    // Return: Returns 0 if no error; else error code, one of which may include:
  34.       #define ERROR_INVALID_FUNCTION         1
  35.       #define ERROR_INVALID_HANDLE           6
  36.       #define ERROR_INVALID_DRIVE            15
  37.       #define ERROR_GEN_FAILURE              31
  38.       #define ERROR_INVALID_PARAMETER        87
  39.       #define ERROR_BUFFER_OVERFLOW          111
  40.       #define ERROR_PROTECTION_VIOLATION     115
  41.       #define ERROR_INVALID_CATEGORY         117
  42.       #define ERROR_BAD_DRIVER_LEVEL         119
  43.       #define ERROR_UNCERTAIN_MEDIA          163
  44.       #define ERROR_MONITORS_NOT_SUPPORTED   165
  45. {
  46.    // Make blobs to hold pointers to parameter size
  47.    BLObPut(_ParameterSize,defined(ParameterSize) ? ParameterSize : 0,UWORD32);
  48.    BLObPut(_DataSize,defined(DataSize) ? DataSize : 0,UWORD32);
  49.  
  50.    // Make sure Parameter and Data blobs are bi enough for return data
  51.    if ( MaxRetParameterSize
  52.      && ( !defined(ParameterBLOb) || NULL == ParameterBLOb || (BLObSize(ParameterBLOb) < MaxRetParameterSize) ) )
  53.       BLObSize(ParameterBLOb,MaxRetParameterSize);
  54.    if ( MaxRetDataSize
  55.      && ( !defined(DataBLOb) || NULL == DataBLOb || (BLObSize(DataBLOb) < MaxRetDataSize) ) )
  56.       BLObSize(DataBLOb,MaxRetDataSize);
  57.  
  58.    // Make call to DosDevIOCtl
  59.    #define ORD_DOS32DEVIOCTL     284
  60.    rc = DynamicLink("doscalls",ORD_DOS32DEVIOCTL,BIT32,CDECL,
  61.                     DevHandle,Category,Function,
  62.                     defined(ParameterBLOb) ? ParameterBLOb : NULL,
  63.                     MaxRetParameterSize,_ParameterSize,
  64.                     defined(DataBLOb) ? DataBLOb : NULL,
  65.                     MaxRetDataSize,_DataSize);
  66.  
  67.    // Return new parameter and data size if they were defined
  68.    if ( MaxRetParameterSize )
  69.       ParameterSize = BLObGet(_ParameterSize,0,UWORD32);
  70.    if ( MaxRetDataSize )
  71.       DataSize = BLObGet(_DataSize,0,UWORD32);
  72.  
  73.    return(rc);
  74. }
  75.  
  76.